/*
 * DB_Object.java
 *
 * Created on May 24, 2000, 12:42 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

import java.util.*;

/**
 *
 * @author ayman
 */
public class MyDB_Object {
    
    private String db_name;
    private Vector tables = new Vector ();; // vector of objects table_object
    
    
    
    /** Creates a new instance of DB_Object */
    public MyDB_Object( String db_name) {
        this.db_name = db_name ;
    }
    public MyDB_Object () {
        
    }
    
    /**
     * This function is called to store the vector of the tables names in 
     * the table objects
     */
    public void setTablesName (Vector tablesNames) {
        
        MyTable_Object tables [] = new MyTable_Object [ tablesNames.size()] ;
        for (int i=0 ; i < tablesNames.size() ; i ++ ){
            tables [i]= new MyTable_Object ();
            tables [i].setTableName((String)tablesNames.elementAt(i));
            this.tables.add(tables [i]);
        }
    }
    
    /**
     * This function is used to set the Fields table for each table
     * it takes in its constructor Vector contains Vectors. The main vector
     * is for a table. each vector contains fields name
     */
    
    public void setFieldsNames (Vector vectorVectorsFields) {
        System.out.println(" number of tables is " + tables.size() + "  and number of tables sent is "+ vectorVectorsFields.size());
        for (int i =0; i < vectorVectorsFields.size() ; i++ ){
            ((MyTable_Object)tables.elementAt(i)).setFieldsNameVector((Vector)vectorVectorsFields.elementAt(i));
        }
    }
    
    /**
     *   This function return the tables of the database
     */
    public Vector getTablesNames () {
        Vector tablesNames = new Vector (); // contains all the tables names
        for (int i =0 ; i < tables.size() ; i++)  {
            tablesNames.add(((MyTable_Object)tables.elementAt(i)).getTableName());
        }
        return (tables);
    }
    
    /**
     *  The function get the fields vector for the given table
     */
    public Vector getFieldsVector (String tableName) {
        Vector fieldsVector = new Vector ();
        
        return fieldsVector;
    }
}



